package cn.com.action;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;



import cn.com.biz.PexaminationBiz;
import cn.com.dao.PexaminationDao;
import cn.com.entity.Pexamination;

import com.opensymphony.xwork2.ActionSupport;

public class PexaminationAction extends ActionSupport implements Serializable,SessionAware{

	private PexaminationBiz pexaminationbiz;
	private Map<String, Object> session;
	private Pexamination pexamination;
	private int pxid;

	public int getPxid() {
		return pxid;
	}

	public void setPxid(int pxid) {
		this.pxid = pxid;
	}

	public PexaminationBiz getPexaminationbiz() {
		return pexaminationbiz;
	}

	public void setPexaminationbiz(PexaminationBiz pexaminationbiz) {
		this.pexaminationbiz = pexaminationbiz;
	}

	public Map<String, Object> getSession() {
		return session;
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public Pexamination getPexamination() {
		return pexamination;
	}

	public void setPexamination(Pexamination pexamination) {
		this.pexamination = pexamination;
	}

	private static final long serialVersionUID = 1L;
//查询所有类别
/*	public String selectpexamination(){
	
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		System.out.println("before");
		PexaminationBiz pexaminationbiz=(PexaminationBiz)ctx.getBean("pexaminationbiz");
		System.out.println("after");
		List<Pexamination> list=pexaminationbiz.selectpexamination();
		System.out.println(list);
		if(list!=null && list.size()==1){
			System.out.println("哥们你不能这样对我呀");
			session.put("list", list);
			System.out.println("hello,word");
		}
		return SUCCESS;
	}*/
	//增加体检
	public String addPexamination(){
		boolean bool=false;
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		pexaminationbiz=(PexaminationBiz)ctx.getBean("pexaminationbiz");
		boolean b=pexaminationbiz.addPexamination(pexamination);
		if(b){
			bool=true;
			return SUCCESS;
		}else{
			return ERROR;
		}
	}
	//删除体检
	public String deletePexamination(){
		boolean bool=false;
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		pexaminationbiz=(PexaminationBiz)ctx.getBean("pexaminationbiz");
		boolean b=pexaminationbiz.deletePexamination(pexamination);
		if(b){
			bool=true;
			return SUCCESS;
		}else{
			return ERROR;
		}
	}
	//修改体检
	public String updatePexamination(){
		boolean bool=false;
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		pexaminationbiz=(PexaminationBiz)ctx.getBean("pexaminationbiz");
		boolean b=pexaminationbiz.updatePexamination(pexamination);
		if(b){
			bool=true;
			return SUCCESS;
		}else{
			return ERROR;
		}
	}
	//查询全部体检
	public String selectPexamination(){
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		pexaminationbiz=(PexaminationBiz)ctx.getBean("pexaminationbiz");
		List<Pexamination> list=pexaminationbiz.selectPexamination();
		if(list!=null){
			session.put("list", list);
			System.out.println("duile");
		}
		return SUCCESS;
	}
	//通过id查询体检
	public String selectPexaminationByid(){
		boolean bool=false;
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		pexaminationbiz=(PexaminationBiz)ctx.getBean("pexaminationbiz");
		Pexamination pexaminationbyid=pexaminationbiz.selectPexaminationByid(pexamination);
		if(pexaminationbyid!=null){
			bool=true;
			session.put("pexaminationbyid", pexaminationbyid);
			
		}
		return SUCCESS;
	}
	/*//查询类别
	public String getonebyid(){
		PexaminationDao pd=new PexaminationDao();
		pexamination=pd.getonebyid(pxid);
		pexamination.getPexaminationpackageset();
		session.put("pexamination", pexamination);
		return SUCCESS;
	}*/
}
